/* Government failure model--Jan 04 */

set more off

use "c:\Data Sets\Africa\africa_1.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu Wgrow WoverS if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

matrix b1=e(b)
matrix v1=e(V)
save "c:\Data Sets\Africa\africa_1.dta", replace

use "c:\Data Sets\Africa\africa_2.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu Wgrow WoverS if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

matrix b2=e(b)
matrix v2=e(V)
save "c:\Data Sets\Africa\africa_2.dta", replace

use "c:\Data Sets\Africa\africa_3.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu Wgrow WoverS if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

matrix b3=e(b)
matrix v3=e(V)
save "c:\Data Sets\Africa\africa_3.dta", replace

use "c:\Data Sets\Africa\africa_4.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu Wgrow WoverS if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

matrix b4=e(b)
matrix v4=e(V)
save "c:\Data Sets\Africa\africa_4.dta", replace

use "c:\Data Sets\Africa\africa_5.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu Wgrow WoverS if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

matrix b5=e(b)
matrix v5=e(V)
save "c:\Data Sets\Africa\africa_5.dta", replace

use "c:\Data Sets\Africa\africa_6.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu Wgrow WoverS if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

matrix b6=e(b)
matrix v6=e(V)
save "c:\Data Sets\Africa\africa_6.dta", replace

use "c:\Data Sets\Africa\africa_7.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu Wgrow WoverS if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

matrix b7=e(b)
matrix v7=e(V)
save "c:\Data Sets\Africa\africa_7.dta", replace

use "c:\Data Sets\Africa\africa_8.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu Wgrow WoverS if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

matrix b8=e(b)
matrix v8=e(V)
save "c:\Data Sets\Africa\africa_8.dta", replace

use "c:\Data Sets\Africa\africa_9.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu Wgrow WoverS if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

matrix b9=e(b)
matrix v9=e(V)
save "c:\Data Sets\Africa\africa_9.dta", replace

use "c:\Data Sets\Africa\africa_10.dta", clear
stset govdur3, failure( pmchg3) id(govid3)
streg intrimgv subsh num_coal seatlar pmpty_s natun civ_war polity nxtpa_el gdpgrowt lagpcgdp imfstatu Wgrow WoverS if nogovrn2==0 & govdurneg==0, dist(w) cluster(code) 

matrix b10=e(b)
matrix v10=e(V)
save "c:\Data Sets\Africa\africa_10.dta", replace

mat B4=b1\b2\b3\b4\b5\b6\b7\b8\b9\b10
matrix row1=[1,1,1,1,1,1,1,1,1,1]
matrix B4mi=(1/10)*([b1\b2\b3\b4\b5\b6\b7\b8\b9\b10]'*row1')
mat V4mi=(v1+v2+v3+v4+v5+v6+v7+v8+v9+v10)/10
mat Sqs=B4-row1'*B4mi'
mat A=Sqs[1, 1...]
mat AA=diag(A)
mat B=Sqs[2, 1...]
mat BB=diag(B)
mat C=Sqs[3, 1...]
mat CC=diag(C)
mat D=Sqs[4, 1...]
mat DD=diag(D)
mat E=Sqs[5, 1...]
mat EE=diag(E)
mat F=Sqs[6, 1...]
mat FF=diag(F)
mat G=Sqs[7, 1...]
mat GG=diag(G)
mat H=Sqs[8, 1...]
mat HH=diag(H)
mat J=Sqs[9, 1...]
mat JJ=diag(J)
mat K=Sqs[10, 1...]
mat KK=diag(K)

mat Sqsq=[A*AA\B*BB\C*CC\D*DD\E*EE\F*FF\G*GG\H*HH\J*JJ\K*KK]'*row1'

mat SE4sq=vecdiag(V4mi)'+(1/9)*Sqsq*(11/10)
mat SE4mi=(vecdiag(cholesky(diag(SE4sq))))'
mat final=[B4mi, SE4mi]
mat colnames final=Coeff StErr
noisily mat list final
